/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////Author: Shahab.Alishahian@gmail.com SA	
///////////////Target:The following methods are here to handle all GAPI functions.
///////////////Version:1.1
///////////////CopyRight: 2014 Noranj Co.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//*************************************************************************************************************
//******Facebook SDK setting

var appId='' ;
var accessToken='' ;
var appAccessToken='' ;
var channelUrl='' ;

if(window.location.href.indexOf("appspot") > -1){
	//JINGLEBOARD
	appId ='0' ;
	channelUrl ='localhost' ;
}
else{
	 //JBCLIENT
	appId='0' ;
	channelUrl='localhost' ;
}
//*************************************************************************************************************
//******Google APi setting 
var clientId = '913666381572.apps.googleusercontent.com'; //jb-shhb->'828062657182-a2i7dlpvhlv2uqe4f101i1430qh1thmr.apps.googleusercontent.com';
var apiKey = 'AIzaSyBrR0uxe3x6G2-ntujf9YURrfE5R9QT728'; //jb-shhb->'AIzaSyCZtTH-e9ZXKkNX07j7RzTtDttNS_JrwfQ';
var scopes = 'https://www.googleapis.com/auth/userinfo.email'; // 'https://www.googleapis.com/auth/plus.me';
var MY_API_ROOT = 'https://shhbjb.appspot.com/_ah/api';
var MY_API_VER = 'v4';
var MY_API_NAME = 'jb';

$.getScript('https://apis.google.com/js/client.js', function() {        
	  $('body').append('<p>GOOGLE API  is loaded</p>');
});

window.onload = function() {
    //gapi.client.setApiKey(apiKey);
    gapi.client.load(MY_API_NAME, MY_API_VER, null, MY_API_ROOT);
}


$(document).ready(function() {
	 $("#ediDivContent").load("htc/edi.txt");
	 $('#xformresult').val('no click');
	 alreadyclicked=false;
	 var today = new Date();
	    $('.me').click(function(){
	    	var el=$(this);
	        if (alreadyclicked){
	            alreadyclicked=false; // reset
	            clearTimeout(alreadyclickedTimeout); // prevent this from happening
	            openPopUp();
	        }else{
	            alreadyclicked=true;
	            console.log('clicked at ' + today);
	            //$('#xformresult').val('clicked');
	            alreadyclickedTimeout=setTimeout(function(){
	                alreadyclicked=false;
	            },300); 
	        }
	        return false;
	    });
	    
	    
		 function openPopUp()
		 {
		   $('#divId').css('display','block');
		   $('#divId').dialog();
		 }
		 
		 $('#closeBox').click(function(){
			$('#divId').css('display','none');
			$('#divId').dialog();
		 });
});

